added SSCLI 1.0
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / VBEFEntityDataModel / TablePerHierarchy / TPHClass.vb
blobef7fa33aa0e6389aff9eced002922ef730825cf0
1 '****************************** Module Header ******************************'
2 ' Module Name: TPHClass.vb
3 ' Project: VBEFEntityDataModel
4 ' Copyright (c) Microsoft Corporation.
6 ' This example demonstrates how to establish table per hierarchy inheritance.
7 ' A table-per-type model is a way to model inheritance where each entity is
8 ' mapped to a distinct table in the store. Then it shows how to query a list
9 ' of people, get the corresponding properties of Person, Student and
10 ' BusinessStudent.
12 ' This source is subject to the Microsoft Public License.
13 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
14 ' All other rights reserved.
16 ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
17 ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
18 ' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
19 '***************************************************************************'
21 #Region "Imports directives"
22 Imports System
23 Imports System.Collections.Generic
24 Imports System.Linq
25 Imports System.Text
26 #End Region
29 Namespace VBEFEntityDataModel.TablePerHierarchy
31 Friend Class TPHClass
33 ' Test the query method in TPHClass
34 Public Shared Sub TPHTest()
35 Query()
36 End Sub
38 ' Query a list of people, print out the properties of Person,
39 ' Student and BusinessStudent
40 Public Shared Sub Query()
41 Using context As New EFTPHEntities()
43 Dim people = From p In context.PersonSet _
44 Select p
46 For Each p In people
47 Console.WriteLine("Student {0} {1}", p.LastName, p.FirstName)
49 If TypeOf p Is Student Then
50 Console.WriteLine("EnrollmentDate: {0}", _
51 DirectCast(p, Student).EnrollmentDate)
52 End If
54 If TypeOf p Is BusinessStudent Then
55 Console.WriteLine("BusinessCredits: {0}", _
56 DirectCast(p, BusinessStudent).BusinessCredits)
57 End If
59 Next
60 End Using
61 End Sub
62 End Class
63 End Namespace